<?php

    $status = (null) ? 'closed' : 'open';
    $url = 'index.php?dir=' . $dir . '&sub=' . $sub;
    
    if ($locations) {
	
	echo '<h4 class="' . $status . '" onclick="swap(this);">Locations (' . sizeof($locations) . ')</h4>';
	echo '<div>';
        echo '<table><tbody>';
        
        echo '<tr><th>#</th><th>ID</th><th>Title</th><th>Address</th><th>Sub-Events</th><th>Vendors</th></tr>';
	
        foreach ($locations as $i=>$location) {
            echo '<tr>';
            echo '<td>' . $i . '</td>';
            echo '<td>' . $location->getId() . '</td>';
            echo '<td><a href"#">' . $location->getTitle() . '</a></td>';
            echo '<td><a href="#">' . $location->getStreet1() . ' ' . $location->getCity() . ', ' . $location->getState()->getAbbreviation() . ' ' . $location->getZip() . '</a></td>';
            echo '<td>' . $location->getSubEventCount() . '</td>';
            echo '<td>' . $location->getVendorCount() . '</td>';
            echo '</tr>';
        }
        echo '</tbody></table>';
        
    } else {
	
	echo '<h4>There are no Locations!</h4>';
	echo '<div>';

    }
    echo '</div>';
    echo '<button class="create" onclick="window.location="' . $url . '&act=edit">Add Location</button>';
    
?>